﻿using System.Collections.Generic;

namespace Telex;

public delegate void SendProtocolDelegate(RpcHost host, uint protocolId, byte[] request);
public delegate void CallProtocolDelegate(RpcHost host, uint protocolId, byte[] request, CallResponseDelegate func);
public delegate void CallResponseDelegate(byte[] response, int opcode);

public interface IRpcChannel
{
    RpcHost LocalHost { get; }
    RpcHost RemoteHost { get; }
    int PipelineCount { get; }
    bool Active { get; }
    IProtocolRegister Register { get; }
    void Send(uint protocolId, byte[] request);
    void Call(uint protocolId, byte[] request, CallResponseDelegate func);
}

sealed class ProtocolMap
{
    public Dictionary<uint, SendProtocolDelegate> sendProtocolMap = new();
    public Dictionary<uint, CallProtocolDelegate> callProtocolMap = new();
}